﻿<UserControl x:Class="ClientOverflow.UserControls.UserProfile"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Converters="clr-namespace:ClientOverflow.UserControls.Converters" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Converters:CollectionToVisibilityConverter x:Key="collectionVisibilityConverter"/>
        <Converters:InverseCollectionToVisibilityConverter x:Key="inverseCollectionVisibilityConverter"/>
    </UserControl.Resources>
    <StackPanel>
        <TextBlock Text="{Binding Path=Email}" />
        <TextBlock Text="{Binding Path=Name}" />

        <ListBox ItemsSource="{Binding Questions}" Visibility="{Binding Questions, Converter={StaticResource collectionVisibilityConverter}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Button Command="{Binding ShowQuestionCommand}">
                        <TextBlock Text="{Binding Title}"/>
                    </Button>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Text="No question" Visibility="{Binding Questions, Converter={StaticResource inverseCollectionVisibilityConverter}}" />

        <ListBox ItemsSource="{Binding Answers}" Visibility="{Binding Answers, Converter={StaticResource collectionVisibilityConverter}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Button Command="{Binding ShowQuestionCommand}">
                        <TextBlock Text="{Binding Title}"/>
                    </Button>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Text="No Answers" Visibility="{Binding Answers, Converter={StaticResource inverseCollectionVisibilityConverter}}" />

        <ListBox ItemsSource="{Binding Tags}" Visibility="{Binding Tags, Converter={StaticResource collectionVisibilityConverter}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Button Command="{Binding ShowQuestions}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding TagName}"/>
                            <TextBlock Text=" x "/>
                            <TextBlock Text="{Binding Occurrences}"/>
                        </StackPanel>
                    </Button>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Text="No Tags" Visibility="{Binding Tags, Converter={StaticResource inverseCollectionVisibilityConverter}}" />

    </StackPanel>
</UserControl>
